home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / lib / python2.6 / lib2to3 / fixes / fix_zip.pyc (.txt) < prev   
Encoding:
Python Compiled Bytecode  |  2009-04-20  |  1.3 KB  |  32 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. """
  5. Fixer that changes zip(seq0, seq1, ...) into list(zip(seq0, seq1, ...)
  6. unless there exists a 'from future_builtins import zip' statement in the
  7. top-level namespace.
  8.  
  9. We avoid the transformation if the zip() call is directly contained in
  10. iter(<>), list(<>), tuple(<>), sorted(<>), ...join(<>), or for V in <>:.
  11. """
  12. from  import fixer_base
  13. from fixer_util import Name, Call, in_special_context
  14.  
  15. class FixZip(fixer_base.ConditionalFix):
  16.     PATTERN = "\n    power< 'zip' args=trailer< '(' [any] ')' >\n    >\n    "
  17.     skip_on = 'future_builtins.zip'
  18.     
  19.     def transform(self, node, results):
  20.         if self.should_skip(node):
  21.             return None
  22.         if in_special_context(node):
  23.             return None
  24.         new = node.clone()
  25.         new.set_prefix('')
  26.         new = Call(Name('list'), [
  27.             new])
  28.         new.set_prefix(node.get_prefix())
  29.         return new
  30.  
  31.  
  32.